let uname = document.getElementById("username");
let upwd = document.getElementById("pwd");
let upwds = document.getElementById("pwds");
let name =   document.getElementById("name");
let unameMsg = document.getElementById("unamemsg");
let upwdMsg = document.getElementById("pwdmsg");
let upwdMsgs = document.getElementById("pwdmsgs");


name.addEventListener("blur",function(){
    
    let val=this.value;
    
    let reg =/^[a-zA-Z0-9_]{2,4}$/ ;
    let bool=reg.test( val)

    if(bool){
        unameMsg.innerHTML="验证通过";
        unameMsg.style.color="orange";

        unameFlag =true
        
    }else{
        unameMsg.innerHTML="验证失败";
        unameMsg.style.color="red";
        unameFlag =false;
    }
    console.log("user:",val,bool);
    
    
})
uname.addEventListener("blur",function(){

    let val=this.value;

    let reg =/^[a-zA-Z0-9_]{6,12}$/ ;
    let bool=reg.test( val)

    if(bool){
        unameMsg.innerHTML="验证通过";
        unameMsg.style.color="orange";
        
 
        unameFlag =true
        
    }else{
        unameMsg.innerHTML="验证失败";
        unameMsg.style.color="red";
        unameFlag =false;
    }
    console.log("user:",val,bool);
    
    
})
upwd.addEventListener("blur",function(){
  
    let val=this.value;

    let reg =/^[a-zA-Z0-9_]{6,12}$/ ;
    let bool=reg.test( val)

    if(bool){
        upwdMsg.innerHTML="验证通过";
        upwdMsg.style.color="orange";
        this.style.borderColor="orange";
        upwdFlag = true;
        
    }else{
        upwdMsg.innerHTML="验证失败";
        upwdMsg.style.color="red";
        this.style.borderColor="red";
        upwdFlag = false;
    }
    console.log("pwd:",val,bool);
    
    
})
pwds.addEventListener("blur",function(){

    let val=this.value;

    let reg =/^[a-zA-Z0-9_]{6,12}$/ ;
    let bool=reg.test( val)

    if(bool){
        upwdMsgs.innerHTML="验证通过";
        upwdMsgs.style.color="orange";
        this.style.borderColor="orange";
        upwdFlag = true;
        
    }else{
        upwdMsgs.innerHTML="验证失败";
        upwdMsgs.style.color="red";
        this.style.borderColor="red";
        upwdFlag = false;
    }
    console.log("pwd:",val,bool);
    
    
})


document.getElementById("logo").onclick=function(){
    window.location="index.html"
}